package com.kuaiyan.sdkshell.ad;

import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.widget.TextView;

import com.kuaiyan.sdkshell.R;

/**
 * Created by wm on 2017/12/18.
 */

public class BaseActivity extends AppCompatActivity {
    private TextView tvTitle;
    protected void initTitleView(){
        tvTitle = (TextView) findViewById(R.id.tv_title);
        Toolbar tlCustom = (Toolbar) findViewById(R.id.tl_custom);
        setSupportActionBar(tlCustom);
        ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) {
            actionBar.setDisplayHomeAsUpEnabled(true);
            actionBar.setDisplayShowTitleEnabled(false);
        }
    }
    protected void setTitleText(String text){
        tvTitle.setText(text);
    }
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                finish();
                break;
        }
        return true;
    }
}
